package randstring

import (
	"math/rand"
	"time"
)

func NewRandString() *RandString {
	return &RandString{}
}

func (r *RandString) RandStr() string {
	var ns = make([]byte, 0, r.N)
	src := rand.New(rand.NewSource(time.Now().UnixNano()))
	for i := 0; i < r.N; i++ {
		ns = append(ns, r.Es[src.Intn(len(r.Es))])
	}
	return string(ns)
}
